<?php

include("header.html");
include("navbar.html");
require_once("../mysql/mysql_connect.php");

$start_date = "2010-10-25";
$end_date = "2010-10-26";
$sensor = $_REQUEST['sensor'];
$start_hour = $_REQUEST['start_hour'];
$start_minute = $_REQUEST['start_minute'];
$start_merid = $_REQUEST['start_merid'];
$end_hour = $_REQUEST['end_hour'];
$end_minute = $_REQUEST['end_minute'];
$end_merid = $_REQUEST['end_merid'];

echo "
    <h2>Time Range View</h2>

    <table id='data'>
 
    <tr>
        <td>Sensor: $sensor</td>
    </tr>
    <tr>
        <td>Range: $start_hour:$start_minute $start_merid
         - $end_hour:$end_minute $end_merid</td>
    </tr>";

if($start_merid == 'pm')
{
    $start_hour = $start_hour + 12;
}

if($end_merid == 'pm')
{
    $end_hour = $end_hour + 12;
}

$start_stamp = $start_date . " " . start_hour . ":" . start_minute . ":" . "00";
$end_stamp = $end_date . " " . end_hour . ":" . end_minute . ":" . "00";

$result_set = mysql_query("CALL RoomNannyDebug.getTimeRangeData($sensor, start_stamp, end_stamp)");

while($row = mysql_fetch_row($result_set))
{

echo "
        <!--Dummy Text-->
        <tr>
            <td>$row[2]</td>
            <td>Door moved:</td>
            <td>$row[5]</td>
        </tr>
        <tr>
            <td>$row[2]</td>
            <td>Light on:</td>
            <td>$row[4]</td>
        </tr>
        <tr>
            <td>$row[2]</td>
            <td>Temperature:</td>
            <td>$row[3]&deg F</td>
        </tr>

    "; //end echo
}

echo "</table>";

include("footer.html");

?>